package com.seeyon.apps.reimburseplugin.dao.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.seeyon.apps.reimburseplugin.dao.ReimburseSonDao;
import com.seeyon.apps.reimburseplugin.po.Reimbursement;
import com.seeyon.apps.reimburseplugin.po.ReimbursementSon;
import com.seeyon.apps.reimburseplugin.po.TemporarySonPO;
import com.seeyon.ctp.util.DBAgent;
import com.seeyon.ctp.util.JDBCAgent;

public class ReimburseSonDaoImpl implements ReimburseSonDao{

	@Override
	public List<TemporarySonPO> findReimburseList(Long formrecordId) {
		Map<String,Object> params=new HashMap<String,Object>();
		String sql=" from TemporarySonPO where formmain_id=:formrecordId";
		params.put("formrecordId", formrecordId);
		List<TemporarySonPO> list=DBAgent.find(sql, params);
		return list;
	}
	@SuppressWarnings({ "deprecation", "resource", "unused" })
	public boolean saveReimbursementSon(ReimbursementSon son) {
		String sql="insert into reimbursement_son(ID,REIMBURSEMENT_ID,START_TIME,END_TIME,START_PLACE,END_PLACE,TRANSPORT,TRAVEL_COSTS,MEALS_DAYS,MEALS_STANDARD,MEALS_NUMBER,MEALS_AMOUNT,TRAVELCOSTS_DAYS,TRAVELCOSTS_STANDARD,TRAVELCOSTS_NUMBER,TRAVELCOSTS_AMOUNT,HOTEL_EXPENSE,OTHER_EXPENSE,SUBTOTAL,MEETING_FEES,SON_TOTAL,REMARK,TAX_AMOUNT,JSFS,ORGTNI_AMOUNT,GLOBALBBJE,DEPTID,ORGTAX_AMOUNT,DWBM,VAT_AMOUNT,ZFYBJE,CJKYBJE,BBJE,ORGVAT_AMOUNT,SZXMID,GROUPBBJE,TNI_AMOUNT,YBJE,JKBXR,ZFBBJE,CREATE_TIME,RES1)"
				+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		List<Object> params=new ArrayList<Object>();
		params.add(son.getId());
		params.add(son.getReimbursementId());
		params.add(son.getStartTime());
		params.add(son.getEndTime());
		params.add(son.getStartPlace());
		params.add(son.getEndPlace());
		params.add(son.getTransport());
		params.add(son.getTravelCosts());
		params.add(son.getMealsDays());
		params.add(son.getMealsStandard());
		params.add(son.getMealsNumber());
		params.add(son.getMealsAmount());
		params.add(son.getTravelCostsDays());
		params.add(son.getTravelCostsStandard());
		params.add(son.getTravelCostsNumber());
		params.add(son.getTravelCostsAmount());
		params.add(son.getHotelExpense());
		params.add(son.getOtherExpense());
		params.add(son.getSubtotal());
		params.add(son.getMeetingFees());
		params.add(son.getSonTotal());
		params.add(son.getRemark());
		params.add(son.getTaxAmount());
		params.add(son.getJsfs());
		params.add(son.getOrgtniAmount());
		params.add(son.getGlobalBbje());
		params.add(son.getDeptId());
		params.add(son.getOrgtaxAmount());
		params.add(son.getDwbm());
		params.add(son.getVatAmount());
		params.add(son.getZfybje());
		params.add(son.getCjkybje());
		params.add(son.getBbje());
		params.add(son.getOrgvatAmount());
		params.add(son.getSzxmid());
		params.add(son.getGroupBbje());
		params.add(son.getTniAmount());
		params.add(son.getYbje());
		params.add(son.getJkbxr());
		params.add(son.getZfbbje());
		params.add(son.getCreateTime());
		params.add(son.getSzxmname());
		int res=0;
		JDBCAgent jdbc=new JDBCAgent();
		try {
			jdbc.batch1Prepare(sql);
			jdbc.batch2Add(params);
			res=jdbc.batch3Execute();
		} catch (Exception e) {
			e.printStackTrace();
		}
		if (res!=0) {
			return true;
		}else {
			return false;
		}
	}
}
